// 路径修正：与 upload.ts 保持一致
import request from "../lib/request";

// 为图片生成文案
export async function generateText(data: {
  imageId: number;
  contentType: string;
  styleType: string;
  customPrompt?: string;
}) {
  return request({
    url: "/ai/text/generate",
    method: "POST",
    data,
  });
}

// 批量生成文案
export async function batchGenerateText(data: {
  imageId: number;
  contentTypes: string[];
  styleTypes: string[];
  customPrompt?: string;
}) {
  return request({
    url: "/ai/text/generate/batch",
    method: "POST",
    data,
  });
}

// 重新生成文案
export async function regenerateText(
  textContentId: number,
  data?: { key?: string }
) {
  return request({
    url: `/ai/text/regenerate/${textContentId}`,
    method: "POST",
    data,
  });
}

// 获取图片的所有文案
export async function getTextsByImage(imageId: number) {
  return request({
    url: `/ai/text/image/${imageId}`,
    method: "GET",
  });
}

// 根据类型和风格获取文案
export async function filterTexts(params: {
  contentType?: string;
  styleType?: string;
}) {
  return request({
    url: "/ai/text/filter",
    method: "GET",
    params,
  });
}

// 删除文案
export async function deleteText(textContentId: number) {
  return request({
    url: `/ai/text/delete/${textContentId}`,
    method: "POST",
  });
}

// 删除图片的所有文案
export async function deleteTextsByImage(imageId: number) {
  return request({
    url: `/ai/text/delete/image/${imageId}`,
    method: "POST",
  });
}

// 重试失败的文案生成
export async function retryFailedTexts() {
  return request({
    url: "/ai/text/retry-failed",
    method: "POST",
  });
}

// 获取文案生成统计信息
export async function getTextStatistics() {
  return request({
    url: "/ai/text/statistics",
    method: "GET",
  });
}
